/**
 * 基础model,系统权限相关功能
 * 在src/store/index.js 中被挂载到store上，命名为 sys
 * **/
import { APIPath } from "@/util/api/index";
import axios from "@/util/axios"; // 自己写的工具函数，封装了请求数据的通用接口
import { message } from "antd";
import { Dispatch } from "@/store";

const defaultState: any = {};

export default {
  state: defaultState,
  reducers: {},

  effects: (dispatch: Dispatch) => ({
    /**
     * ZS 条件分页查询客户列表
     * **/
    async getClientList(params: {
      page: number;
      limit: number;
      [keys: string]: any;
    }) {
      try {
        const res: any = await axios.get(APIPath.getUsers, {
          params,
        });
        return res;
      } catch (err) {
        message.error("网络错误，请重试");
      }
      return;
    },

    async getDepoistLogs(params: {
      page: number;
      limit: number;
      [keys: string]: any;
    }) {
      try {
        const res: any = await axios.get(APIPath.getDepoistLogs, {
          params,
        });
        return res;
      } catch (err) {
        message.error("网络错误，请重试");
      }
      return;
    },

    async getWithdrawLogs(params: {
      page: number;
      limit: number;
      [keys: string]: any;
    }) {
      try {
        const res: any = await axios.get(APIPath.getWithdrawLogs, {
          params,
        });
        return res;
      } catch (err) {
        message.error("网络错误，请重试");
      }
      return;
    },

    async getExchangeLigs(params: {
      page: number;
      limit: number;
      [keys: string]: any;
    }) {
      try {
        const res: any = await axios.get(APIPath.getExchangeLigs, {
          params,
        });
        return res;
      } catch (err) {
        message.error("网络错误，请重试");
      }
      return;
    },

    async getDistributionList(params: {
      page: number;
      limit: number;
      [keys: string]: any;
    }) {
      try {
        const res: any = await axios.get(APIPath.getDistribution, {
          params,
        });
        return res;
      } catch (err) {
        message.error("网络错误，请重试");
      }
      return;
    },
  }),
};
